home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / FromTheMag / JW FLV MEDIA PLAYER 4.2 / mediaplayer.exe / player.swf / scripts / com / jeroenwijering / parsers / ASXParser.as next >
Text File  |  2008-11-04  |  2KB  |  78 lines

  1. package com.jeroenwijering.parsers
  2. {
  3.    import com.jeroenwijering.utils.Strings;
  4.    
  5.    public class ASXParser extends ObjectParser
  6.    {
  7.        
  8.       
  9.       public function ASXParser()
  10.       {
  11.          super();
  12.       }
  13.       
  14.       public static function parse(param1:XML) : Array
  15.       {
  16.          var _loc2_:Array = null;
  17.          var _loc3_:Object = null;
  18.          var _loc4_:XML = null;
  19.          _loc2_ = new Array();
  20.          _loc3_ = new Object();
  21.          for each(_loc4_ in param1.children())
  22.          {
  23.             _loc3_ = ASXParser.parseItem(_loc4_);
  24.             if(_loc3_["type"] != undefined)
  25.             {
  26.                _loc2_.push(_loc3_);
  27.             }
  28.             _loc3_ = {};
  29.          }
  30.          return _loc2_;
  31.       }
  32.       
  33.       public static function parseItem(param1:XML) : Object
  34.       {
  35.          var _loc2_:Object = null;
  36.          var _loc3_:XML = null;
  37.          _loc2_ = new Object();
  38.          for each(_loc3_ in param1.children())
  39.          {
  40.             if(!_loc3_.localName())
  41.             {
  42.                break;
  43.             }
  44.             switch(_loc3_.localName().toLowerCase())
  45.             {
  46.                case "ref":
  47.                   _loc2_["file"] = _loc3_.@href.toString();
  48.                   continue;
  49.                case "title":
  50.                   _loc2_["title"] = _loc3_.text().toString();
  51.                   continue;
  52.                case "moreinfo":
  53.                   _loc2_["link"] = _loc3_.@href.toString();
  54.                   continue;
  55.                case "abstract":
  56.                   _loc2_["description"] = _loc3_.text().toString();
  57.                   continue;
  58.                case "author":
  59.                   _loc2_["author"] = _loc3_.text().toString();
  60.                   continue;
  61.                case "duration":
  62.                   _loc2_["duration"] = Strings.seconds(_loc3_.@value);
  63.                   continue;
  64.                case "starttime":
  65.                   _loc2_["start"] = Strings.seconds(_loc3_.@value);
  66.                   continue;
  67.                case "param":
  68.                   _loc2_[_loc3_.@name] = _loc3_.@value.toString();
  69.                   continue;
  70.                default:
  71.                   continue;
  72.             }
  73.          }
  74.          return ObjectParser.complete(_loc2_);
  75.       }
  76.    }
  77. }
  78.